package com.lbw.singleton;

/**
 * @author lbw
 * @version 1.0
 * @date 2021/9/4 22:52
 * 懒汉式, 延迟加载, 使用双重检测锁模式,保证线程安全
 */
public class Singleton4 {
    private static volatile Singleton4 INSTANCE;

    private Singleton4() {

    }

    public static Singleton4 getInstance() {
        if (INSTANCE == null) {
            synchronized (Singleton4.class) {
                if (INSTANCE == null) {
                    INSTANCE = new Singleton4();
                }
            }
        }
        return INSTANCE;
    }
}
